<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('查看产品信息')" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-manage-add" th:object="${manage}">
        <input type="hidden" name="manageId" id="manageId" th:field="*{manageId}">
        <div class="form-group">
            <label class="col-sm-3 control-label">品名：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="manageName" id="manageName" th:field="*{manageName}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">图片信息： </label>
            <div class="col-sm-8">
                <select class="form-control noselect2 selectpicker" id="priMesId" name="priMesId" >
                    <option value="">请选择系列</option>
                    <option th:each="dict : ${picture}" th:text="${dict.priMesName}" th:value="${dict.priMesId}" th:selected="${manage.priMesId ==  dict.priMesId  ? true : false}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">类别：</label>
            <div class="col-sm-8">
                <select class="form-control noselect2 selectpicker" name="manageCategory" id="manageCategory" >
                    <option value="1" th:selected="${manage.manageCategory == 1 ? true : false}">家具</option>
                    <option value="2" th:selected="${manage.manageCategory == 2 ? true : false}">饰品</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">系列： </label>
            <div class="col-sm-8">
                <select class="form-control noselect2 selectpicker" id="seriesId" name="seriesId" >
                    <option value="">请选择系列</option>
                    <option th:each="dict : ${series}" th:text="${dict.seriesName}" th:value="${dict.seriesId}" th:selected="${manage.seriesId ==  dict.seriesId  ? true : false}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">风格： </label>
            <div class="col-sm-8">
                <select class="form-control noselect2 selectpicker" id="styleId" name="styleId" >
                    <option value="">请选择风格</option>
                    <option th:each="dict : ${style}" th:text="${dict.styleName}" th:value="${dict.styleId}" th:selected="${manage.styleId == dict.styleId ? true : false}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">规格： </label>
            <div class="col-sm-8">
                <select class="form-control noselect2 selectpicker" id="speId" name="speId" >
                    <option value="">请选择系列</option>
                    <option th:each="dict : ${specification}" th:text="${dict.speName}" th:value="${dict.speId}" th:selected="${manage.speId == dict.speId ? true : false}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">材质：</label>
            <div class="col-sm-8">
                <select class="form-control noselect2 selectpicker" name="manageTexture" id="manageTexture">
                    <option value="1" th:selected="${manage.manageTexture == 1 ? true : false}">面料</option>
                    <option value="2" th:selected="${manage.manageTexture == 2 ? true : false}">五金件</option>
                    <option value="3" th:selected="${manage.manageTexture == 3 ? true : false}">木饰面</option>
                    <option value="4" th:selected="${manage.manageTexture == 4 ? true : false}">油漆</option>
                    <option value="5" th:selected="${manage.manageTexture == 5 ? true : false}">其他</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">产地：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="manageOrigin" id="manageOrigin" th:field="*{manageOrigin}"  required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">单价：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="managePrice" id="managePrice" th:field="*{managePrice}"   required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">数量：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="manageNumber" id="manageNumber" th:field="*{manageNumber}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">金额：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="manageMoney" id="manageMoney" th:field="*{manageMoney}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea id="manageDesc" name="manageDesc" class="form-control" th:field="*{manageDesc}" >[[*{manageDesc}]]</textarea>
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<script type="text/javascript">

    function edit() {
        var manageId = $("input[name='manageId']").val();
        var manageName = $("input[name='manageName']").val();
        var priMesId = $("select[name='priMesId']").val();
        var manageCategory = $("select[name='manageCategory']").val();
        var seriesId = $("select[name='seriesId']").val();
        var styleId = $("select[name='styleId']").val();
        var speId = $("select[name='speId']").val();
        var manageTexture = $("select[name='manageTexture']").val();
        var manageOrigin = $("input[name='manageOrigin']").val();
        var managePrice = $("input[name='managePrice']").val();
        var manageNumber = $("input[name='manageNumber']").val();
        var manageMoney = $("input[name='manageMoney']").val();
        var manageDesc = $("textarea[name='manageDesc']").val();
        $.ajax({
            cache : true,
            type : "POST",
            url : ctx + "datum/manage/edit",
            data : {
                "manageId": manageId,
                "manageName": manageName,
                "priMesId": priMesId,
                "manageCategory": manageCategory,
                "seriesId": seriesId,
                "styleId": styleId,
                "speId": speId,
                "manageTexture": manageTexture,
                "manageOrigin": manageOrigin,
                "managePrice": managePrice,
                "manageNumber": manageNumber,
                "manageMoney": manageMoney,
                "manageDesc": manageDesc,
            },
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                $.operate.successCallback(data);
            }
        });
    }

    function submitHandler() {
        if ($.validate.form()) {
            edit();
        }
    }
</script>
</body>
</html>
